package com.jms.fu.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class GetCountCart extends Action{

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		HttpSession session = request.getSession();
		PrintWriter out = null;
		try {
			out = response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
		int i=0;
		if(session.getAttribute("cart")!=null){
			ArrayList<Integer> cart =  (ArrayList<Integer>)session.getAttribute("cart");
			i = cart.size();
		}
		out.print("View <i style='margin-left:5px' class='fa fa-compress'>("+i+")</i>");
		out.close();
		return null;
	}
	
}
